home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / ripdump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  962 b   |  55 lines

  1. #include "global.h"
  2. #include "mbuf.h"
  3. #include "netuser.h"
  4. #include "timer.h"
  5. #include "rip.h"
  6. #include "trace.h"
  7.  
  8. void rip_dump(fp,bpp)
  9. FILE *fp;
  10. struct mbuf **bpp;
  11. {
  12.     struct rip_route entry;
  13.     int i;
  14.     int cmd,version;
  15.     int16 len;
  16.     
  17.     fprintf(fp,"RIP: ");
  18.     cmd = PULLCHAR(bpp);
  19.     version = PULLCHAR(bpp);
  20.     switch(cmd){
  21.     case RIPCMD_REQUEST:
  22.         fprintf(fp,"REQUEST");
  23.         break;
  24.     case RIPCMD_RESPONSE:
  25.         fprintf(fp,"RESPONSE");
  26.         break;
  27.     default:
  28.         fprintf(fp," cmd %u",cmd);
  29.         break;
  30.     }
  31.  
  32.     pull16(bpp);    /* remove one word of padding */
  33.  
  34.     len = len_p(*bpp);
  35.     fprintf(fp," vers %u entries %u:\n",version,len / RIPROUTE);
  36.  
  37.     i = 0;
  38.     while(len >= RIPROUTE){
  39.         /* Pull an entry off the packet */
  40.         pullentry(&entry,bpp);
  41.         len -= RIPROUTE;
  42.  
  43.         if(entry.addr_fam != RIP_IPFAM) {
  44.             /* Skip non-IP addresses */
  45.             continue;
  46.         }
  47.         fprintf(fp,"%-16s%-3u ",inet_ntoa(entry.target),entry.metric);
  48.         if((++i % 3) == 0){
  49.             putc('\n',fp);
  50.         }
  51.     }
  52.     if((i % 3) != 0)
  53.         putc('\n',fp);
  54. }
  55.